#ifndef GET_PAGE_H
#define GET_PAGE_H
#include <string>
#include <vector>
#include <netdb.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <fstream>

using namespace std;
class GetPage{
private:
  static size_t SIZE_PER_READ;
  void get_addr_list();
  vector<struct addrinfo*> addr_list_;
  void free_addr_list();
  bool retrieve_file(int sockfd);
  bool send_request(int sockfd);
  bool get_connect(struct addrinfo& addr);
  void finish(fstream&, int, char*);
  int start_of_data(char*&, int& cnt);
public:
  string host_, file_, port_, output_file_;
  GetPage(){};
  GetPage(string host, string file, string port, string output_file);
  string get_page();
};
#endif
